package controllers

import (
	"github.com/beego/beego/v2/client/orm"
	beego "github.com/beego/beego/v2/server/web"
	"year/models"
)

type ShowController struct {
	beego.Controller
}

func (s *ShowController) Form() {
	s.TplName = "form.html"
}
func (s *ShowController) Show() {
	o := orm.NewOrm()
	var u = []models.Users{}
	_, err := o.QueryTable("users").All(&u)
	if err != nil {
		s.Data["json"] = map[string]interface{}{
			"code": 400,
			"msg":  "查询失败",
		}
		s.ServeJSONP()
		return
	}
	s.Data["data"] = u
	s.TplName = "show.html"
}
